package model

import "time"

type Filedata struct {
	Id        int       `json:"id"`
	Userid    int       `json:"userid"`
	Filename  string    `json:"filename"`
	Filehash  string    `json:"filehash"`
	Fileurl   string    `json:"fileurl"`
	Filethumb string    `json:"filethumb"`
	Size      int       `json:"size"`
	Source    int       `json:"source"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetByFilehash(filehash string) (file Filedata, count int) {
	DB.Where("filehash = ?", filehash).First(&file).Count(&count)
	return file, count
}

func AddFiledata(filedata Filedata) (num int64) {
	num = DB.Create(&filedata).RowsAffected
	return num
}
